package com.bjwl.service.impl;

import com.bjwl.dao.BusinessMapper;
import com.bjwl.pojo.Business;
import com.bjwl.pojo.Staff;
import com.bjwl.pojo.vo.QueryBusinessVo;
import com.bjwl.service.BusinessService;
import com.bjwl.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @Author: czc
 * @Date:Create：in 2020/4/14 11:25
 * @Description:业务管理seviceImpl
 * @Modified By：
 * @Version: 1.0
 */
@Service
public class BusinessServiceImpl implements BusinessService {

    @Autowired
    private BusinessMapper businessMapper;


    @Override
    @Transactional
    public List<Business> byBsIdFindBusinessC(Integer branchstoreid) {
        return businessMapper.byBsIdFindBusinessC(branchstoreid);
    }

    @Override
    public Business updateShowBusinese(Integer id) {
        return businessMapper.updateShowBusinese(id);
    }

    //根据业务id修改业务信息
    @Override
    @Transactional
    public void updateBusinessByid(Business business) {
        businessMapper.updateBusinessByid(business);
    }
    //根据当前业务id删除当前业务
    @Override
    public void deleteBusinese(Integer buid) {

        businessMapper.deleteBusinese(buid);
    }

    @Override
    @Transactional
    public void addBusiness(Business business) {
        businessMapper.addBusiness(business);
    }

    @Override
    public PageBean<Business> findAllBusiness(QueryBusinessVo queryBusinessVo) {
        PageBean<Business> pageBean = new PageBean<>(queryBusinessVo.getPageNum(),10,businessMapper.getTotalRecord(queryBusinessVo));
        pageBean.setData(businessMapper.findAllBusiness(pageBean,queryBusinessVo));

        return pageBean;
    }

    @Override
    public Integer finBusinessCount(Integer bsid) {
        return businessMapper.finBusinessCount(bsid);
    }

    @Override
    public Integer findAllBusinessTotalRecord() {
        return businessMapper.findAllBusinessTotalRecord();
    }


    @Override
    public PageBean<Business> findBusinessBS(Integer pageNum, Integer branchstoreid, String bstarttime, String bendtime,Integer bopid ,String bopvalue,Integer bsstate){
        PageBean<Business> pageBean = new PageBean<Business>(pageNum,10,businessMapper.businessPaging(branchstoreid,bopid,bopvalue,bstarttime,bendtime,bsstate));
        pageBean.setData(businessMapper.findBusinessBS(pageBean,branchstoreid,bstarttime,bendtime,bopid,bopvalue,bsstate));
        return pageBean;
    }

}
